define([
    'dojo/on',
    'dojo/_base/lang',
    'dojo/date/locale',
    'dojo/number'
], function (on, lang, locale, number) {

    //portrait letter
//  var pageWidth = 612;
//  var pageHeight = 792;
//  var pageCenter = 306;

    //landscape letter
      var pageWidth = 792;
      var pageHeight = 612;
      var pageCenter = 346;

//  var colors = {
//      text: [33, 33, 33],
//      line: [15, 53, 101],
//      border: [99, 99, 99],
//      subheading: [15, 53, 101],
//      heading: [15, 53, 101],
//      transparent: [255, 255, 255, 0],
//      white: [255, 255, 255]
//  };
//
//  var fonts = {
//      text: {
//          color: colors.text,
//          size: 11,
//          font: 'helvetica',
//          style: 'normal'
//      },
//      heading: {
//          color: colors.heading,
//          size: 14,
//          style: 'bold'
//      },
//      rowHeading: {
//          color: colors.subheading,
//          size: 11,
//          style: 'bold'
//      },
//      footer: {
//          color: colors.text,
//          size: 9,
//          style: 'italic'
//      }
//  };

//  var formatOptions = {
//      Number: {
//      	places: 2
//      }
//  };

    return {
        map: true,
        topicID: 'reportWidget',
        
//      pageWidth: 612,
//  	pageHeight: 792,
//  	pageCenter: 306,
//
//		colors: {
//      	text: [33, 33, 33],
//	        line: [15, 53, 101],
//	        border: [99, 99, 99],
//	        subheading: [15, 53, 101],
//	        heading: [15, 53, 101],
//	        transparent: [255, 255, 255, 0],
//	        white: [255, 255, 255]
// 		},
// 		
// 		fonts: {
//	        text: {
//	            //color: colors.text,
//	            color: [33, 33, 33],
//	            size: 11,
//	            font: 'helvetica',
//	            style: 'normal'
//	        },
//	        heading: {
//	            //color: colors.heading,
//	            color: [15, 53, 101],
//	            size: 14,
//	            style: 'bold'
//	        },
//	        rowHeading: {
//	            //color: colors.subheading,
//	            color: [15, 53, 101],
//	            size: 11,
//	            style: 'bold'
//	        },
//	        footer: {
//	            //color: colors.text,
//	            color: [33, 33, 33],
//	            size: 9,
//	            style: 'italic'
//	        }
//  	},
        /*
            printTaskURL must be on the same server as application
            or the server must be configured for CORS
            or you can use a proxy
        */
       
        printTaskURL: '',

        defaultStyles: {
            //font: fonts.text,
            font: {
	            color: [33, 33, 33],
	            size: 11,
	            font: 'helvetica',
	            style: 'normal'
	        },
            line: {
                width: 0.5,
                //color: colors.line
                color: [15, 53, 101]
            },
            rectangle: {
                lineWidth: 0.5,
                //lineColor: colors.border,
                lineColor: [99, 99, 99],
                //fillColor: colors.transparent
                fillColor: [255, 255, 255, 0]
            }
        },

        reportLayout: {
            layout: {
                orientation: 'portrait',
                unit: 'pt',
                format: 'letter'
            },
            output: {
                type: 'save',
                options: 'report.pdf'
            },
            margins: {
                top: 30,
                left: 30,
                bottom: 30,
                right: 30
            },
            metadata: {
                title: '地块报告',
                author: '临港集团',
                keywords: '地块, 指标',
                creator: '临港集团'
            },
            header: {
                text: [
                    {
                        text: '临港地块报告',
                        left: 306,
                        top: 55,
                        align: 'center',
                        font: {
                            //color: colors.heading,
                            color: [15, 53, 101],
                            size: 20,
                            style: 'bold'
                        }
                    }
                ],
                lines: [
                    {
                        left: 35,
                        top: 65,
                        bottom: 65,
                        right: pageWidth - 35,
                        width: 1.5,
                        //color: colors.line
                        color: [15, 53, 101]
                    }
                ],
                attributes: [
                    {
                        top: 35,
                        left: pageWidth - 140,
                        layout: 'stacked',
                        fields: [
                            {
                                fieldName: 'LANDUSENAME',
                                label: '规划性质名称'
                            }
                        ]
                    }
                ]
            },
            footer: {
                text: [
                    {
                        format: 'date',
                        left: 38,
                        top: pageHeight - 30,
                        //font: fonts.footer
                        font: {
				            color: [33, 33, 33],
				            size: 9,
				            style: 'italic'
				        }
                    },
                    {
                        format: 'pageNumber',
                        left: pageCenter,
                        top: pageHeight - 30,
                        align: 'center',
                        //font: fonts.footer
                        font: {
				            color: [33, 33, 33],
				            size: 9,
				            style: 'italic'
				        }
                    },
                    {
                        text: 'Anytown, USA',
                        left: pageWidth - 38,
                        top: pageHeight - 30,
                        align: 'right',
                        //font: fonts.footer
                        font: {
				            color: [33, 33, 33],
				            size: 9,
				            style: 'italic'
				        }
                    }
                ],
                lines: [
                    {
                        left: 35,
                        top: pageHeight - 40,
                        bottom: pageHeight - 40,
                        right: pageWidth - 35,
                        width: 0.5,
                        //color: colors.line
                        color: [15, 53, 101]
                    }
                ]
            },
            map: {
                top: 80,
                left: 35,
                height: 266,
                width: 266,
                dpi: 144,  //multiple of 72
                format: 'JPG',
                preserveScale: false,
                border: true
            },
            text: [],
            lines: [],
            pages: [], // you can group everything related to each individual page, if desired
            groupedItems: [], // for grouped items such as text on top of a graphic or shape
            shapes: [], // types: circle, ellipse, rectangle, square, triangle
            tables: [],
            attributes: [
                {
                    layout: 'column',
                    options: {
                        margin: {top: 110, left: pageCenter + 5, bottom: 35, right: 0},
                        tableWidth: 266,
                        theme: 'grid',
                        /*style: tableStyle,*/
                        styles: {
                            fontSize: 10,
                            cellPadding: 5,
                            //fillColor: colors.white,
                            fillColor: [15, 53, 101],
                            valign: 'top', // top, middle, bottom
                            overflow: 'linebreak', // visible, hidden, ellipsize or linebreak
                            labelWidth: 95
                        }
                    },
                    fields: [
                        {
                            fieldName: 'LANDUSENAME',
                            label: '规划性质名称',
                            rowHeading: {
                                text: '规划指标',
                                //font: fonts.rowHeading
                                font: {
						            color: [15, 53, 101],
						            size: 11,
						            style: 'bold'
						        }
                            }
                        },
                        {
                            fieldName: 'SHAPE.AREA',
                            label: '地块面积',
                            //formatOptions: formatOptions.number
                            formatter: function (value) {
                            	return number.format(value);
                        	}
                        }
                    ]
                }
			]
        }
    };
});